from flask import Flask, render_template, jsonify
from flask_cors import CORS
import random

from word_read import run

app = Flask(__name__, static_folder='./static', static_url_path='/web/', template_folder='./static')
CORS(app)


@app.route('/web/')
def hello_world():
    return render_template('index.html')


@app.route('/web/api/word_handle')
def word_handle():
    return run()


@app.route('/api/getRandomNum')
def get_random_num():
    res = {
        'getRandomNum': random.randint(1, 100)
    }
    return jsonify(res)


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=False, threaded=True)
    # app.run()
